package com.gxm.base.thread.completablefure;

import org.junit.Test;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

public class CFutrue {
    @Test
    public void test01() throws ExecutionException, InterruptedException {
        CompletableFuture<String> completableFuture = CompletableFuture.supplyAsync(() -> {
            System.out.println("有返回结果的,异步编排线程执行了!");
            // 延迟2秒
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            return "hello";
        });
        System.out.println("异步编排前执行了VGA   8!");
        System.out.println(completableFuture.get());
        System.out.println("main线程执行了!");
    }
}
